2992684fe20fa57a11496e26eacd1b69ec5a8672,esc/src/main/java/org/cloudifysource/esc/driver/provisioning/storage/openstack/OpenstackStorageDriver.java,OpenstackStorageDriver,detachVolume,#String#String#number#TimeUnit#,158

Before Change


		Optional<? extends VolumeAttachmentApi> volumeAttachmentApi = 
				getAttachmentApi(node.getLocation().getParent().getId());
		
		if (volumeAttachmentApi.isPresent()) {
			volumeAttachmentApi.get().detachVolumeFromServer(volumeId, node.getProviderId());
		} else {
			throw new StorageProvisioningException("Failed to detach volume " + volumeId 
					+ ", Openstack API is not initialized.");

After Change


		Optional<? extends VolumeApi> volumeApi = getVolumeApi();
		Optional<? extends VolumeAttachmentApi> volumeAttachmentApi = getAttachmentApi();
		
		if (!volumeApi.isPresent() || !volumeAttachmentApi.isPresent()) {
			throw new StorageProvisioningException("Failed to detach volume " + volumeId 
					+ ", Openstack API is not initialized.");
		}
		
		volumeAttachmentApi.get().detachVolumeFromServer(volumeId, node.getProviderId());
		
		try {
			waitForVolumeToReachStatus(Volume.Status.AVAILABLE, volumeApi, volumeId, endTime);